#pragma once

#include <vector>

namespace solution_075
{

class Solution
{
public:
    void sortColors(std::vector<int>& nums)
    {
        int last_zero = -1;
        int first_two = nums.size();
        for (int i = 0; i < first_two; ) {
            switch (nums.at(i)) {
                case 0: std::swap(nums.at(i++), nums.at(++last_zero)); break;
                case 2: std::swap(nums.at(i), nums.at(--first_two)); break;
                default: ++i;
            }
        }
    }
};

}  /* namespace solution_075 */
